home *** CD-ROM | disk | FTP | other *** search
- // ===========================================================================
- // myDNS.h ©1999 Sustainable Softworks, All rights reserved.
- // ===========================================================================
- // dns protocol definitions
-
- #ifndef _H_myDNS
- #define _H_myDNS
- #pragma once
-
- // DNS header
- struct dns_header_t
- {
- UInt16 queryID;
- UInt16 queryParameter; // flags
- UInt16 QDCount; // questions
- UInt16 ANCount; // answer RRs
- UInt16 NSCount; // authority RRs
- UInt16 ARCount; // additional RRs
- };
- typedef struct dns_header_t dns_header_t;
-
- // DNS resource record
- struct dns_record_t
- {
- UInt16 rdType;
- UInt16 rdClass;
- UInt32 rdTTL;
- UInt16 rdLength;
- };
- typedef struct dns_record_t dns_record_t;
- // define size as a constant since the sizeof(dns_record_t)
- // can vary depending on alignment.
- const SInt16 kdns_record_size = 10;
-
- // dns UDP message
- typedef struct DNSMessage {
- UInt8 op; // operation (1=request, 2=reply)
- } DNSMessage_t;
-
- const SInt16 kDNSResponseReady = 1;
-
-
-
- // Query Types
- const UInt16 kQTypeA = 1;
- const UInt16 kQTypeCNAME = 5;
- const UInt16 kQTypeHINFO = 13; // Host info (CPU & OS)
- const UInt16 kQTypeMINFO = 14; // Mailbox Info
- const UInt16 kQTypeMX = 15; // Mail Exchanger
- const UInt16 kQTypeNS = 2; // Authoritative Name Server
- const UInt16 kQTypePTR = 12;
- const UInt16 kQTypeSOA = 6;
- const UInt16 kQTypeTXT = 16;
- const UInt16 kQTypeAAAA = 28; // IP6 Address
- const UInt16 kQTypeAXFR = 252; // Zone Transfer
- const UInt16 kQTypeALL = 255; // All Resource Records
- const UInt16 kQTypePrivate = 256;
- //const UInt16 kQTypeLS = kQTypePrivate + 1; // List Domains
-
- // Query Type hash values
- // Hash query types as the sum of octets in the corresponding PString.
- // Hash values are used to compare the query type in a GURL string.
- const UInt16 kHashA = 1 + 'A';
- const UInt16 kHashCNAME = 5 + 'C' + 'N' + 'A' + 'M' + 'E';
- const UInt16 kHashHINFO = 5 + 'H' + 'I' + 'N' + 'F' + 'O';
- const UInt16 kHashMINFO = 5 + 'M' + 'I' + 'N' + 'F' + 'O';
- const UInt16 kHashMX = 2 + 'M' + 'X';
- const UInt16 kHashNS = 2 + 'N' + 'S';
- const UInt16 kHashPTR = 3 + 'P' + 'T' + 'R';
- const UInt16 kHashSOA = 3 + 'S' + 'O' + 'A';
- const UInt16 kHashTXT = 3 + 'T' + 'X' + 'T';
- const UInt16 kHashAAAA = 4 + 'A' + 'A' + 'A' + 'A';
- const UInt16 kHashAXFR = 4 + 'A' + 'X' + 'F' + 'R';
- const UInt16 kHashALL = 1 + ('*' & 0xDF);
- const UInt16 kHashLS = 2 + 'L' + 'S';
-
- // Query Class
- const UInt16 kQClassIN = 1;
-
- // Query Code masks
- // 1 1 1 1 1 1
- // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
- // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- // |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
- // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- const UInt16 kQueryMaskQR = 0x8000;
- const UInt16 kQueryMaskOPCODE = 0x7800;
- const UInt16 kQueryMaskAA = 0x0400;
- const UInt16 kQueryMaskTC = 0x0200;
- const UInt16 kQueryMaskRD = 0x0100;
- const UInt16 kQueryMaskRA = 0x0080;
- const UInt16 kQueryMaskRCODE = 0x000F;
-
- // Default Column positions
- const SInt16 kDNSColumn1 = 4;
- const SInt16 kDNSColumn2 = 30;
- const SInt16 kDNSColumn3 = 36;
- const SInt16 kDNSColumn4 = 44;
- const SInt16 kDNSColumn5 = 66;
-
- const SInt16 kNSLookupText = 244; // resource ID for col pos
-
- #endif